package com.example.mall.service.impl;

import com.example.mall.dto.ChartDto;
import com.example.mall.mbg.mapper.CustomScoreMapper;
import com.example.mall.mbg.mapper.ScoreMapper;
import com.example.mall.mbg.model.Score;
import com.example.mall.mbg.model.ScoreExample;
import com.example.mall.service.ScoreService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ScoreServiceImpl
 * Created by on 2023/12/27.
 */
@Service
public class ScoreServiceImpl implements ScoreService {
    @Autowired
    private ScoreMapper scoreMapper;
    @Autowired
    private CustomScoreMapper customScoreMapper;

    @Override
    public List<Score> listAll() {
        return scoreMapper.selectByExample(new ScoreExample());
    }

    @Override
    public int create(Score score) {
        return scoreMapper.insertSelective(score);
    }

    @Override
    public int update(Integer scoreid, Score score) {
        score.setScoreid(scoreid);
        return scoreMapper.updateByPrimaryKeySelective(score);
    }

    @Override
    public int delete(Integer scoreid) {
        return scoreMapper.deleteByPrimaryKey(scoreid);
    }

    @Override
    public List<Score> list(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return scoreMapper.selectByExample(new ScoreExample());
    }

    @Override
    public Score get(Integer scoreid) {
        return scoreMapper.selectByPrimaryKey(scoreid);
    }

    @Override
    public List<Score> getScoreList() {
        return customScoreMapper.getScoreList();
    }

    @Override
    public void deleteAll() {
        customScoreMapper.deleteAll();
    }

    @Override
    public List<ChartDto> getChartList(String period) {
        return customScoreMapper.getChartList(period);
    }

    @Override
    public List<ChartDto> getChartDetail(Integer supplierid, String period) {
        return customScoreMapper.getChartDetail(supplierid, period);
    }

    @Override
    public List<String> getPeriodList() {
        return customScoreMapper.getPeriodList();
    }
}
